<?php
$where_clause = 'WHERE ';
if ($do === 'alterSelect') {
	
} else {
}
$SelectStatement = "SELECT * FROM `album` ";
$SelectQuery = mysql_query($SelectStatement);

if ($do === 'updateCds') {
	$i = 0;
	$artist = $_POST['artist'];
	$title = $_POST['title'];
	$title = $_POST['title'];
	$add_date = $_POST['add_date'];
	foreach ($_POST['cddbid'] as $cddbid) {
		echo("UPDATE `album` 
		SET `artist`='".mysql_real_escape_string($artist[$i])."',
		`title`='".mysql_real_escape_string($title[$i])."',
		`slot`='".mysql_real_escape_string($slot[$i])."',
		`add_date`='".mysql_real_escape_string($add_date[$i])."'
		WHERE `cddbid`='".$cddbid."' <br />"
		);
		$i++;
	}
//	echo($CD_update_query);
}

?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="hidden" name="cat" value="<?=$cat?>" />
<input type="hidden" name="mode" value="cdmassedit" />
<input type="hidden" name="do" value="alterSelect" />
<input type="submit" value="Show CDs" /><input type="reset" value="Cancel" />
</form><br /><br />
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="submit" value="Save All Changes" /><input type="reset" value="Cancel Changes" />
<table>
<tr><th>Artist</th><th>Title</th><th>Slot</th><th>Add Date</th></tr>
<?php 
$albumCount = 0;
while ($SelectRow = mysql_fetch_array($SelectQuery)) {
	echo ('<tr><td>');
	echo('<input type="hidden" name="cddbid[' . $albumCount . ']" value="' . $SelectRow[cddbid] . '"  /><input type="text" name="artist[' . $albumCount . ']" value="' . $SelectRow[artist] . '" /></td><td><input type="text" name="title[' . $albumCount . ']" value="' . $SelectRow[title] . '" /></td><td><input type="text" name="slot[' . $albumCount . ']" value="' . $SelectRow[slot] . '" /></td><td><input type="text" name="add_date[' . $albumCount . ']" value="' . $SelectRow[add_date] . '" />' . "\n" );
	echo ('</td></tr>');
	$albumCount++;
}
?>
</table>
<input type="hidden" name="mode" value="cdmassedit" />
<input type="hidden" name="do" value="updateCds" />
<input type="hidden" name="cat" value="<?=$cat?>" />
<input type="submit" value="Save All Changes" /><input type="reset" value="Cancel Changes" />
</form>